package com.example.dddsample.infrastructure.persistence.assembler.mapper;


import com.example.dddsample.domain.entity.CustomerAggregate;
import com.example.dddsample.infrastructure.persistence.po.CustomerPo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author: bebm
 * @date: 2022/3/29 14:18
 * @description:
 */
@Mapper
public interface CustomerPoMapper {


    CustomerPoMapper INSTANCE = Mappers.getMapper( CustomerPoMapper.class );

    @Mappings({
            @Mapping(target="custId",source="source.custId"),
            @Mapping(target="custName",source="source.custName"),
            @Mapping(target="addressVO.province",source="source.province"),
            @Mapping(target="addressVO.city",source="source.city"),
            @Mapping(target="addressVO.addressDetail",source="source.address")
    })
    CustomerAggregate fromCustomerPo(CustomerPo source);

    List<CustomerAggregate> fromCustomerPo(List<CustomerPo> source);
}
